#ifndef CH_DRAWRECT_H
#define CH_DRAWRECT_H

#pragma once

class CHDrawRect
{
public:

	static void PrepareDraw(HWND hWnd, HDC& hDC, RECT& rect )
	{
	   GetWindowRect(hWnd, &rect);         
	   OffsetRect(&rect, -rect.left, -rect.top);
	   hDC = GetWindowDC(hWnd);
	}

	static void MyFillSolidRect(HDC hDC, const RECT& rect, COLORREF clr )
	{
	   SetBkColor( hDC, clr );
	   ExtTextOut( hDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL );
	}

	static void MyFillSolidRect( HDC hDC, int x, int y, int cx, int cy, COLORREF clr )
	{
	   RECT rect;
	   SetRect( &rect, x, y, x + cx, y + cy );
	   MyFillSolidRect(hDC, rect, clr);
	}

	static void Draw3dRect( HDC hDC, int x, int y, int width, int height,
				COLORREF clrTopLeft, COLORREF clrBottomRight )
	{
	   MyFillSolidRect( hDC, x, y, width - 1, 1, clrTopLeft );
	   MyFillSolidRect( hDC, x, y, 1, height - 1, clrTopLeft );
	   MyFillSolidRect( hDC, x + width, y, -1, height, clrBottomRight );
	   MyFillSolidRect( hDC, x, y + height, width, -1, clrBottomRight );
	}

	static void Draw3dRect( HDC hDC, const RECT& rect, COLORREF clrTopLeft, COLORREF clrBottomRight )
	{
	   Draw3dRect( hDC, rect.left, rect.top, rect.right - rect.left,
					rect.bottom - rect.top, clrTopLeft, clrBottomRight );
	}

	static void Draw3dBorder( HDC hDC, const RECT& rc, 
					  COLORREF clrWTopLeft, COLORREF clrWBottomRight,
					  COLORREF clrNTopLeft, COLORREF clrNBottomRight)
	{
	   Draw3dRect( hDC, rc, clrWTopLeft, clrWBottomRight);
	   Draw3dRect( hDC, rc.left + 1, rc.top + 1, rc.right - rc.left - 2, rc.bottom - rc.top - 2, 
							clrNTopLeft, clrNBottomRight);
	}
};


#endif //CH_DRAWRECT_H